;(function () {
  new Vue({
    el: '#my-cm',
    data: {
      customerList: [],
      customerListAct: '#',
      customerTypeList: [],
      customerTypeListAct: '#',
      industryList: [],
      industryAct: '#',
      channelTypeList: [],
      channelTypeAct: '#',
      channelNameList: [],
      channelNameAct: '#',
      submenuList: [
        {name: '未跟进过', count: 0, code: 'FMWF'},
        {name: '跟进中', count: 0, code: 'FMFI'},
        {name: '逾期未跟进', count: 0, code: 'FMOWF'}
      ],
      submenuListAct: 'FMWF',
      keyWord: '',
      pageCounts: [10, 15, 20],
      limit: 10,
      page: 1,
      orders: 'ASC',
      data: {},

    },
    methods: {
      getcustomerList () {
        hlhttp.get({
          url: 'configure/dict',
          data: {module_code: 'ZHSH', config_name: 'ZS_CUSTOMER_STATUS'},
          success: res => {
            res.unshift({dictCode:"#",dictName:"全部",seq:"0",status:"Y",type:"S"})
            this.customerList = res;
          }
        })
      },
      getcustomerTypeList () {
        hlhttp.get({
          url: 'configure/dict',
          data: {module_code: 'ZHSH', config_name: 'ZS_CUSTOMER_TYPE'},
          success: res => {
            res.unshift({dictCode:"#",dictName:"全部",seq:"0",status:"Y",type:"S"})
            this.customerTypeList = res;
          }
        })
      },
      getindustryList () {
        hlhttp.get({
          url: 'configure/industry/dict',
          success: res => {
            res.unshift({code:"#",name:"全部"})
            this.industryList = res;
          }
        })
      },
      getchannelTypeList () {
        hlhttp.get({
          url: 'configure/dict',
          data: {module_code: 'ZHSH', config_name: 'ZS_CHANNEL_CATE'},
          success: res => {
            res.unshift({dictCode:"#",dictName:"全部",seq:"0",status:"Y",type:"S"})
            this.channelTypeList = res;
          }
        })
      },
      getchannelNameList () {
        hlhttp.get({
          url: 'configure/dict',
          data: {module_code: 'ZHSH', config_name: 'ZS_CHANNEL_NAME'},
          success: res => {
            res.unshift({dictCode:"#",dictName:"全部",seq:"0",status:"Y",type:"S",parentDictCode:"#"})
            this.channelNameList = res;
          }
        })
      },
      setchannelNameAct (code) {
        this.channelTypeAct = code;
        this.$refs.channelName.innerHTML = '请选择';
        this.channelNameAct = '#';
      },
      setSubmenuAct (code) {
        this.submenuListAct = code;
      },
      setMoreNum (n) {
        this.limit = n;
      },
      setorders () {
        this.orders = this.orders == 'ASC' ? 'DESC' : 'ASC';
        this.getData()
      },
      getData () {
        hlhttp.get({
          url: 'customer/cmt_user_search',
          data: {
            "customer_state": this.customerListAct,
            "customer_type": this.customerTypeListAct,
            "industry": this.industryAct,
            "channel_category_code": this.channelTypeAct,
            "channel_name_code": this.channelTypeAct,
            "status": this.submenuListAct,
            "keyword": this.keyWord,
            "limit": this.limit,
            "page": this.page,
            "columns": "LUT",
            "orders": this.orders
          },
          success: res => {
            this.data = res;
            $("#page").initPage(res.totalPage, this.page, (n) => {
              if (this.page == n) return;
              this.page = n;
              this.getData()
            });
          }
        })
      },

    },
    mounted () {
      this.getcustomerList()
      this.getcustomerTypeList()
      this.getindustryList()
      this.getchannelTypeList()
      this.getchannelNameList()
      this.getData()
      hlSelectUi()
    }
  })
} ())
